/**
 * 
 */
package com.estock.common.util;

import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

/**
 * @author richard
 *
 */
public class AppCtx implements ApplicationContextAware {

    private static ApplicationContext ctx;
    
    @Override
    public void setApplicationContext(ApplicationContext arg0) {
        if (ctx != null) {
            throw new IllegalStateException("context has already been initialized");
        }
        ctx = arg0;
    }
    
    public static ApplicationContext getCtx() {
        if (ctx == null) {
            throw new IllegalStateException("context has not been initialized");
        }
        return ctx;
    }

    public static void resetDTProcAppCtx() {
        ctx = null;
    }

}
